package com.zhentao.service.impl;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zhentao.common.Result;
import com.zhentao.domain.Area;
import com.zhentao.service.AreaService;
import com.zhentao.mapper.AreaMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author 86133
* @description 针对表【area(区域表)】的数据库操作Service实现
* @createDate 2024-09-06 10:00:56
*/
@Service
public class AreaServiceImpl extends ServiceImpl<AreaMapper, Area>
    implements AreaService{
    @Autowired
    private StringRedisTemplate stringRedisTemplate;
    @Override
    public Result getAreaList(Integer cityId) {
        String area = stringRedisTemplate.opsForValue().get("area");
        List<Area> areasList = JSON.parseArray(area, Area.class);
        List<Area> result = areasList.stream().filter(item -> item.getPid().equals(cityId)).toList();
        return Result.build(result, 200, "查询成功");
    }
}




